{	Problem: http://codeforces.ru/problemset/problem/26/B
	Verdict: Accepted

}
var i,n,cur:longint; s:string;
begin
readln(s);
n:=0;
cur:=0;
for i:=1 to length(s) do begin
  if (s[i]=')') and (cur>0) then begin
    inc(n);
    dec(cur);
  end else
  if (s[i]='(') then inc(cur);
end;
writeln(n*2);
readln;
end.